import request from '@/utils/request'
// 登录
export function login(userPhone, password, code) {
  return request({
    url: '/iot/user/login',
    method: 'post',
    data: {
      userPhone,
      password,
      code
    }
  })
}

// export function getInfo() {
//   return request({
//     url: '/session/info',
//     method: 'get'
//   })
// }
export function verifyCode() {
  return request({
    url: '/iot/user/verifyCode',
    method: 'get'
  })
}
export function logout() {
  return request({
    url: '/iot/user/sign_out',
    method: 'get'
  })
}
// 新建用户
export function registered(data) {
  return request({
    url: '/iot/user/registered',
    method: 'post',
    data
  })
}
// 查询用户
export function GetUserList(params) {
  return request({
    url: '/iot/user/get_user_list',
    method: 'get',
    params
  })
}
// 修改用户
export function updateUser(params) {
  return request({
    url: '/iot/user/update_user',
    method: 'put',
    params
  })
}
// 修改密码
export function updatePassword(data) {
  return request({
    url: '/iot/user/update_password',
    method: 'put',
    data
  })
}
// 删除用户
export function deletedUser(params) {
  return request({
    url: '/iot/user/deleted_user',
    method: 'delete',
    params
  })
}
const userList = {
  userName: {
    label: '用户名',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0,
    rule: () => {
      return new Error()
    }
  },
  userPhone: {
    label: '电话号码',
    center: true,
    sort: false,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  },
  // pass: {
  //   label: '密码',
  //   center: true,
  //   sort: true,
  //   show: true,
  //   type: 'string',
  //   disabled: false,
  //   width: 0
  // },
  role: {
    label: '角色',
    center: true,
    show: true,
    sort: true,
    type: 'string',
    disabled: false,
    width: 0
  }

  // email: {
  //   label: '电子邮箱',
  //   center: true,
  //   sort: true,
  //   show: true,
  //   type: 'string',
  //   disabled: false,
  //   width: 0
  // }
}
export function users() {
  return userList
}
